import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Default from "../views/Double12.vue";


const routes: Array<RouteRecordRaw> = [
    {
        path: "/double12",
        name: "double12",
        meta: {
            title: "挺想租-双十二"
        },
        component: Default
    },
    {
        path: "/unicom",
        name: "unicom",
        meta: {
            title: "挺想租-联通活动"
        },
        component: () => import("../views/Unicom.vue")
    },
    {
        path: "/spring",
        name: "spring",
        meta: {
            title: "挺想租-春季优惠"
        },
        component: () => import("../views/Spring.vue")
    },
    {
        path: "/promotion",
        name: "promotion",
        meta: {
            title: "挺想租-商户推广"
        },
        component: () => import("../views/promotion.vue")
    },
    {
        path: "/:pathMatch(.*)*",
        redirect: "/spring",
    }
]


const router = createRouter({
    history: createWebHistory(),
    routes,
})


router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title as string;
    } else {
        document.title = "挺想租"
    }
    next()
})

export default router;